package org.visionlibrary.image.filters.clustering.proto.model;

public class ColorSample extends CounterSample {
	public ColorSample(int hue, int sat, int val) {
		super(hue, sat, val);
	}
	
	@Override
	public double distanceFrom(Sample sample) {
		double d = 0;
		if (Math.abs(hue - sample.hue) > (180 / hQ))
			d = Math.pow((360 / hQ) - Math.abs(hue - sample.hue), 2);
		else
			d = Math.pow(hue - sample.hue, 2);

		return d + Math.pow(sat - sample.sat, 2) + Math.pow(val - sample.val, 2);
	}
	
	@Override
	public String toString() {
		return "ColorSample" + super.toString();
	}
}
